clear all

import excel "mturk.xlsx", sheet("Political+Violence+-+Study+1_No") firstrow

set scheme plotplain

*pid
gen PID=pid
recode PID 1=2 2=6 3/4=4
recode PID 2=1 if pidd==1
recode PID 6=7 if pidr==1
recode PID 4=3 if pidi==1
recode PID 4=5 if pidi==2
gen PIDext=abs(PID-4)
gen ideoext=abs(ideo-4)

*demos
recode sex 2/3=0, gen(male)
recode race 1=1 2/5=0, gen(white)
recode military 2=0

*attention
rename BPAQ_2 attention
recode attention 1=1 *=0
drop if attention!=1

*values
rename _value value1
rename _mca mca1
rename _mcn mcn1
rename _mcd mcd1
rename AO value2
rename AP mca2
rename AQ mcn2
rename AR mcd2
rename AS value3
rename AT mca3
rename AU mcn3
rename AV mcd3
rename AW value4
rename AX mca4
rename AY mcn4
rename AZ mcd4
rename BA value5
rename BB mca5
rename BC mcn5
rename BD mcd5
rename BE value6
rename BF mca6
rename BG mcn6
rename BH mcd6
rename BI value7
rename BJ mca7
rename BK mcn7
rename BL mcd7
rename BM value8
rename BN mca8
rename BO mcn8
rename BP mcd8
rename BQ value9
rename BR mca9
rename BS mcn9
rename BT mcd9
rename BU value10
rename BV mca10
rename BW mcn10
rename BX mcd10
rename BY value11
rename BZ mca11
rename CA mcn11
rename CB mcd11
rename CC value12
rename CD mca12
rename CE mcn12
rename CF mcd12
rename CG value13
rename CH mca13
rename CI mcn13
rename CJ mcd13
rename CK value14
rename CL mca14
rename CM mcn14
rename CN mcd14
rename CO value15
rename CP mca15
rename CQ mcn15
rename CR mcd15
rename CS value16
rename CT mca16
rename CU mcn16
rename CV mcd16
rename CW value17
rename CX mca17
rename CY mcn17
rename CZ mcd17
rename DA value18
rename DB mca18
rename DC mcn18
rename DD mcd18
rename DE value19
rename DF mca19
rename DG mcn19
rename DH mcd19
rename DI value20
rename DJ mca20
rename DK mcn20
rename DL mcd20
rename DM value21
rename DN mca21
rename DO mcn21
rename DP mcd21
rename DQ value22
rename DR mca22
rename DS mcn22
rename DT mcd22
rename DU value23
rename DV mca23
rename DW mcn23
rename DX mcd23
rename DY value24
rename DZ mca24
rename EA mcn24
rename EB mcd24
rename EC value25
rename ED mca25
rename EE mcn25
rename EF mcd25
rename EG value26
rename EH mca26
rename EI mcn26
rename EJ mcd26
rename EK value27
rename EL mca27
rename EM mcn27
rename EN mcd27
rename EO value28
rename EP mca28
rename EQ mcn28
rename ER mcd28
rename ES value29
rename ET mca29
rename EU mcn29
rename EV mcd29
rename EW value30
rename EX mca30
rename EY mcn30
rename EZ mcd30
rename FA value31
rename FB mca31
rename FC mcn31
rename FD mcd31
rename FE value32
rename FF mca32
rename FG mcn32
rename FH mcd32
rename FI value33
rename FJ mca33
rename FK mcn33
rename FL mcd33
rename FM value34
rename FN mca34
rename FO mcn34
rename FP mcd34
rename FQ value35
rename FR mca35
rename FS mcn35
rename FT mcd35
rename FU value36
rename FV mca36
rename FW mcn36
rename FX mcd36
rename FY value37
rename FZ mca37
rename GA mcn37
rename GB mcd37
rename GC value38
rename GD mca38
rename GE mcn38
rename GF mcd38
rename GG value39
rename GH mca39
rename GI mcn39
rename GJ mcd39
rename GK value40
rename GL mca40
rename GM mcn40
rename GN mcd40
rename _Q59 value41
rename _Q60 mca41
rename _Q61 mcn41
rename _Q62 mcd41
rename GS value42
rename GT mca42
rename GU mcn42
rename GV mcd42
rename GW value43
rename GX mca43
rename GY mcn43
rename GZ mcd43
rename HA value44
rename HB mca44
rename HC mcn44
rename HD mcd44
rename HE value45
rename HF mca45
rename HG mcn45
rename HH mcd45
rename HI value46
rename HJ mca46
rename HK mcn46
rename HL mcd46
rename HM value47
rename HN mca47
rename HO mcn47
rename HP mcd47
rename HQ value48
rename HR mca48
rename HS mcn48
rename HT mcd48
rename HU value49
rename HV mca49
rename HW mcn49
rename HX mcd49
rename HY value50
rename HZ mca50
rename IA mcn50
rename IB mcd50
rename IC value51
rename ID mca51
rename IE mcn51
rename IF mcd51
rename IG value52
rename IH mca52
rename II mcn52
rename IJ mcd52
rename IK value53
rename IL mca53
rename IM mcn53
rename IN mcd53
rename IO value54
rename IP mca54
rename IQ mcn54
rename IR mcd54
rename IS value55
rename IT mca55
rename IU mcn55
rename IV mcd55
rename _Q63 value56
rename _Q64 mca56
rename _Q65 mcn56
rename _Q66 mcd56
rename JA value57
rename JB mca57
rename JC mcn57
rename JD mcd57
rename JE value58
rename JF mca58
rename JG mcn58
rename JH mcd58
rename JI value59
rename JJ mca59
rename JK mcn59
rename JL mcd59
rename JM value60
rename JN mca60
rename JO mcn60
rename JP mcd60
rename JQ value61
rename JR mca61
rename JS mcn61
rename JT mcd61
rename JU value62
rename JV mca62
rename JW mcn62
rename JX mcd62
rename JY value63
rename JZ mca63
rename KA mcn63
rename KB mcd63
rename KC value64
rename KD mca64
rename KE mcn64
rename KF mcd64
rename KG value65
rename KH mca65
rename KI mcn65
rename KJ mcd65
rename KK value66
rename KL mca66
rename KM mcn66
rename KN mcd66
rename KO value67
rename KP mca67
rename KQ mcn67
rename KR mcd67
rename KS value68
rename KT mca68
rename KU mcn68
rename KV mcd68
rename KW value69
rename KX mca69
rename KY mcn69
rename KZ mcd69
rename LA value70
rename LB mca70
rename LC mcn70
rename LD mcd70
rename LE value71 
rename LF mca71
rename LG mcn71
rename LH mcd71
rename LI value72
rename LJ mca72
rename LK mcn72
rename LL mcd72
rename LM value73
rename LN mca73
rename LO mcn73
rename LP mcd73
rename LQ value74
rename LR mca74
rename LS mcn74
rename LT mcd74
rename LU value75
rename LV mca75
rename LW mcn75
rename LX mcd75
rename LY value76
rename LZ mca76
rename MA mcn76
rename MB mcd76
rename MC value77
rename MD mca77
rename ME mcn77
rename MF mcd77
rename MG value78
rename MH mca78
rename MI mcn78
rename MJ mcd78
rename MK value79
rename ML mca79
rename MM mcn79
rename MN mcd79
rename MO value80
rename MP mca80
rename MQ mcn80
rename MR mcd80
rename MS value81
rename MT mca81
rename MU mcn81
rename MV mcd81
rename MW value82
rename MX mca82
rename MY mcn82
rename MZ mcd82
rename NA value83
rename NB mca83
rename NC mcn83
rename ND mcd83
rename NE value84
rename NF mca84
rename NG mcn84
rename NH mcd84
rename NI value85
rename NJ mca85
rename NK mcn85
rename NL mcd85
rename NM value86
rename NN mca86
rename NO mcn86
rename NP mcd86
rename NQ value87
rename NR mca87
rename NS mcn87
rename NT mcd87

*recoding agreement with reversed value statements
recode value58 1=5 2=4 4=2 5=1
recode value59 1=5 2=4 4=2 5=1
recode value62 1=5 2=4 4=2 5=1
recode value63 1=5 2=4 4=2 5=1
recode value65 1=5 2=4 4=2 5=1
recode value67 1=5 2=4 4=2 5=1
recode value69 1=5 2=4 4=2 5=1
recode value71 1=5 2=4 4=2 5=1
recode value77 1=5 2=4 4=2 5=1
recode value79 1=5 2=4 4=2 5=1
recode value80 1=5 2=4 4=2 5=1
recode value83 1=5 2=4 4=2 5=1
recode value84 1=5 2=4 4=2 5=1
recode value87 1=5 2=4 4=2 5=1

forval x=1/87 {
	egen mc`x'=rowfirst(mca`x' mcn`x' mcd`x')
	recode value`x' 1/2=1 3=0 4/5=-1, gen(valuetri`x')
	recode value`x' 1=5 2=4 4=2 5=1
}
drop mcn* mca* mcd*

* descriptive stats: Table A1 in OA
tabstat PID male white age educ, stat(min max mean sd N) col(stat)

** reshaping **
gen RespID=_n
reshape long value valuetri mc, i(RespID) j(item)
rename value support
rename valuetri supportri

gen typology=.
replace typology=1 if item<=40
replace typology=2 if item>40 & item<56
replace typology=3 if item>55

gen value=.
*schwartz
replace value=1 if item<5
replace value=2 if item>4 & item<8
replace value=3 if item>=8 & item<=11
replace value=4 if item>=12 & item<=14
replace value=5 if item>=15 & item<=20
replace value=6 if item>=21 & item<=24
replace value=7 if item>=25 & item<=29
replace value=8 if item>=30 & item<=32
replace value=9 if item>=33 & item<=36
replace value=10 if item>=37 & item<=40
*mfq
replace value=11 if item==41
replace value=11 if item==46
replace value=11 if item==51
replace value=12 if item==42
replace value=12 if item==47
replace value=12 if item==52
replace value=13 if item==43
replace value=13 if item==48
replace value=13 if item==53
replace value=14 if item==44
replace value=14 if item==49
replace value=14 if item==54
replace value=15 if item==45
replace value=15 if item==50
replace value=15 if item==55
*political
replace value=16 if item>=56 & item<=63
replace value=17 if item>=64 & item<=71
replace value=18 if item>=72 & item<=73
replace value=19 if item>=74 & item<=75
replace value=20 if item>=76 & item<=81
replace value=21 if item>=82 & item<=87

label define valuel 1 "S: Self-Direction" 2 "S: Hedonism" 3 "S: Benevolence" 4 "S: Power" 5 "S: Universalism" 6 "S: Achievement" 7 "S: Security" 8 "S: Stimulation" 9 "S: Conformity" 10 "S: Tradition" 11 "MF: Care" 12 "MF: Fairness" 13 "MF: Loyalty" 14 "MF: Authority" 15 "MF: Sanctity" 16 "P: Equality" 17 "P: Humanitarianism" 18 "P: Moral Traditionalism" 19 "P: Moral Tolerance" 20 "P: Individualism" 21 "P: Limited Gov't"
label values value valuel

label define typologyl 1 "Schwartz" 2 "MFT" 3 "Political", replace
label values typology typologyl

recode support 1/3=0 4/5=1, gen(suppdi)

*typology: Figure A1 in OA and model 1 of Table D1 in Dataverse

mixed mc ibn.typology if support>3, nocons || RespID:
est store t1
test 2.typology=3.typology
test 2.typology=1.typology
coefplot t1, keep(*typology) xlab(3.25(.25)4.25) order(1.typology 3.typology 2.typology) xtitle("Moralization") saving(typology_mturk.gph, replace) legend(off)

*values: Figure A3 in OA and model 1 of Table D2 in Dataverse

mixed mc ibn.value if support>3, nocons || RespID:
est store v1
* benevolence vs. care/fairness
test 3.value=11.value
test 3.value=12.value
* universalism vs. care/fairness
test 5.value=11.value
test 5.value=12.value
* conformity vs. sanctity
test 9.value=15.value
* tradition vs. loyalty/authority
test 10.value=13.value
test 10.value=14.value
* equality vs. fairness
test 16.value=12.value
* humanitarianism vs. fairness
test 17.value=12.value
* moral traditionalism vs. sanctity
test 18.value=15.value
* moral tolerance vs. sanctity
test 19.value=15.value
* security vs. loyalty
test 7.value=13.value
* security vs. self-drection
test 7.value=1.value

gen valcoef=.
gen valse=.
forval x=1/21 {
replace valcoef = _b[`x'.value] in `x'
replace valse=_se[`x'.value] in `x'
}

coefplot v1, keep(*value) xlab(2(.5)5) order(4.value 8.value 6.value 2.value 1.value 7.value 10.value 3.value 5.value 9.value 20.value 21.value 19.value 16.value 18.value 17.value 14.value 13.value 15.value 12.value 11.value) subtitle("MTurk Sample") xtitle("Moralization") saving(value_mturk.gph, replace)

keep valcoef
rename valcoef valcoefmturk
gen val = _n

save "comparing samples", replace
